#include "character.h"
#include "game_engine.h"

character::character(float x,float y,AI_behavior* behav): lastupdate( clock() ),
behavior( behav ), target( NULL ), package( NULL ){
    coord.x = x;
    coord.y = y;
}

character::character(fcoord fc,AI_behavior* behav): coord(fc), lastupdate( clock() ),
behavior( behav ), target( NULL ), package( NULL ){}

character::~character(){
    if( behavior )  delete behavior;
    if( target )    delete target;
    if( package )   delete package;
}

void character::execAI(clock_t now){
    if( behavior )  behavior->AI_exec(this,now);
    if( target )    target->AI_exec(this,now);
    if( package )   package->AI_exec(this,now);
}

void character::setBehavior(AI_behavior* behav){
    if( behavior ) delete behavior;
    behavior = behav;
}

